Conversation
|
I've rebased on the branch #127, on the assumption that it will get merged before this one. Many thanks to @julianstirling for rebasing #127 on |
This has also included some work setting up docstring linting with `pydoclint` and tweaking `ruff` rules to flag docstring issues. Ruff does not check sphinx format docstrings very well, so I'm now using `pydoclint` directly. This should go in CI. I have retained the docstring-related Ruff rules that work, because it's useful to have them applied in pre-commit hooks.
I've turned off class attribute checks: I prefer one docstring per attribute. We may need to revisit this as per-attribute docstrings are not enforced.
I've added a `wot_td_` reference, because this needs to be referred to quite frequently.
I've added an explicit reference for "using things from other things". This may well want to be its own page in the future.
I've renamed `task` to `invocation` for consistency, and eliminated a couple of pointless functions.
I thought adding a type annotation to `Invocation.action` would be a simple improvement, but it confuses mypy badly. I have removed the annotation and the error is gone, but we should fix it properly later - I've added a note to NOTES.md. I also forgot to delete the `as_responses` argument from a call to `invocations()`, this is now fixed. Thanks for spotting that, mypy.
I've moved content from the `actions` module docstring into a page in the conceptual docs, so it can be linked to more effectively. There are a few new/improved type hints as well.
I've disabled this rule in favour of proper type hinting.
I have swapped a `raise` for an `assert` as I don't expect the condition should ever be false.
This also addresses an issue with pre-made dependencies, and updates the example code to use Annotated directly.
sphinx-autodoc2 gives difficult-to-follow errors that don't easily show where in the source they come from. I've set up flake8 to lint the docstrings, and fixed the errors. I've also fixed my links, which used incorrect syntax for `:ref:` links. I may try out sphinx.ext.autodoc instead - this imports the module, but might be more reliable.
Swap sphinx autodoc2 for autoapi. I've also added sphinx to dev requirements so we don't use a separate venv for docs. This may require readthedocs to be reconfigured. I've updated dev-requirements.txt to latest versions. There were a lot of ambiguous references, which I've eliminated by using a sphinx skip member function to deduplicate symbols that were re-exported (intentionally or otherwise). More use of __all__ may help here - or hiding some more modules. I've fixed up some more rst issues, too.
I also changed a couple of imports that confused autoapi - these were confusing anyway (importing external symbols from submodules).
I've excluded tests and examples from docstring lint, for now.
This also runs pydoclint as a plugin.
Self lives in typing_extensions until we stop supporting 3.10.
The CI will still test Python 3.10, but only with unpinned dependencies. This is because dependencies are usually upgraded using python >=3.11, and newer numpy versions no longer support v3.10. Keeping Python 3.10 in the unpinned-dependencies test should check it will still work, we just don't have to lock the project based on the older Python version.
`Thing._settings` should never be None, and I've relaxed typing so that `Thing` is properly recognised as an async context manager again by mypy.
|
This is frustratingly close to being ready. I think all the code changes are done - I've excluded tests from docstring linting for now, that is a future job. Currently, error tracebackI'll try to debug this - I think once it is fixed this will be ready for review. |
dev-dependencies.txt was regenerated under python 3.10, so numpy is no longer 2.3 and will install. I've set flake8 to only run under python 3.12 and 3.13 - it fails on older Python, but passes with no errors on 3.12 and 3.13. Given that we're linting rather than testing, I think there's little advantage to doing it four times, so I will disable that step on 3.10 and 3.11, and spend the time fixing something else.
The Sphinx error is the same as the flake8 error on Python 3.11. Changing the build version on readthedocs should fix the problem. I also now need to install the package for readthedocs (as I import it in `conf.py` to exclude some symbols). I've added `python.install.path: .` which I hope will do that.
|
Docs can be viewed at https://labthings-fastapi--138.org.readthedocs.build/en/138/ |
|
Thanks @rwb27, clearly a huge amount of work has gone into this and the docs on ReadTheDocs look so much more complete. I still need to do a bit of a read through, and I am sure I will learn a lot. The two things I noticed in my very very speedy click through are:
|
|
I've updated |
|
Thanks for spotting |
julianstirling
left a comment
There was a problem hiding this comment.
This is an incredible amount of work thank you @rwb27.
I have done a high level walk through of this. I think we won't truly know what else needs to be done with the docs until we start using them in anger.
I've spotted a couple of little things. I think also probably clearest to remove the examples directory if it is empty.
|
Thanks for that - typos are fixed and examples folder is gone. I put an examples page in the docs with links, I thought it would be helpful to point people to examples, but it's the right call to lose the examples folder. I'm under no illusion that the docs are now finished, but it's a significant step in the right direction and hopefully we'll continue to build the higher level docs pages as we go. |
In this PR, I intend to go through every function and check:
:param <name>:syntaxI will make notes as I go in
NOTES.mdfor my convenience. This file should be deleted before merging. Those notes will include any additions to the conceptual docs required - ideally I'd implement those as part of this PR, but if not I should at least raise an issue to note that they are missing.I may add type hints and delete vestigial code as I go - I'll detail that in commit messages by way of explanation.
I have added most of the
ruffrules inDandDOCto the section inpyproject.toml, however this doesn't properly check sphinx-style docstrings and won't verify parameters are documented. I have therefore addedpydoclintand configured it to work for sphinx.I intend in the future to make code examples in documentation testable with
doctest. However, I think this probably ought to be left for a future PR. In this PR I will convert code blocks to use the ReST.. code-block::syntax, so it will become easier to find and upgrade them to doctest-compatible ones in the future.I will try to restrain myself from any serious refactoring or code changes, even if I spot things that I'd like to tweak. I will try to note these instead, for a future tidy-up. The occasional type hint or unused variable is, I think, fair game.
Things to check at the end:
pydoclintis run in CI[ ] This is rebased onmainonce Use type hints on properties instead ofmodelargument #127 is merged